package com.huqing.icu.dao;

import com.huqing.icu.mapper.ChatMessageMapper;
import com.huqing.icu.model.ChatMessage;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Repository;

/**
 * @Description 对话消息表dao
 * @Author huqing
 * @Date 2025/7/26 17:38
 **/
@Repository
public class ChatMessageDao {

    @Resource
    private ChatMessageMapper chatMessageMapper;

    public void saveOrUpdate(ChatMessage chatMessage) {
        if (chatMessage.getId() == null) {
            chatMessageMapper.insert(chatMessage);
        } else {
            chatMessageMapper.updateById(chatMessage);
        }
    }

    public Integer updateToken(Long id, Integer token) {
        return chatMessageMapper.updateToken(id, token);
    }
}
